﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sunboxsoft.Common;

namespace Sunboxsoft.ASMS.Server.Domain.UnitTest
{
    [TestClass]
    public class QueryServiceUnitTest
    {
        private Service.QueryService _service;
        public QueryServiceUnitTest()
        {
            Logger.InitByLogDirectory(System.Configuration.ConfigurationManager.AppSettings["SYS.LogDirectory"]);
            Domain.Library.Load();
            _service = new Service.QueryService();
        }

        [TestMethod]
        public void TestQueryServiceCategoryPagedList()
        {
            //PagedResult<Entity.EServiceCategory> result = _service.QueryServiceCategoryPagedList(0, 999);
            //Assert.IsTrue(result.IsSuccess);
        }

        [TestMethod]
        public void TestQueryServiceItemPagedList()
        {
            //PagedResult<Entity.EServiceItem> result = _service.QueryServiceItemPagedList(null,
            //    new Guid("{647AE906-43F8-447B-A7AB-90DCD09E41CC}"),
            //    new Guid("{0EB976A2-5A5A-4E67-A434-CD0E70E69AEA}"),  1, 0, 999);
            //Assert.IsTrue(result.IsSuccess);
        }

        [TestMethod]
        public void TestQueryAutomobileList()
        {
            ListResult<View.VAutomobile> result = _service.QueryAutomobileList(new Guid("CFAF8933-AB12-4C58-A2F9-7BA2188F8D02"));
            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }

        [TestMethod]
        public void TestQueryBookingBillPagedList()
        {
            Guid businessId = new Guid("{647AE906-43F8-447B-A7AB-90DCD09E41CC}");
            Guid stationId = new Guid("{0EB976A2-5A5A-4E67-A434-CD0E70E69AEA}");
            PagedResult<View.VBookingBill> result = _service.QueryBookingBillPagedList(businessId, stationId, DateTime.Now.AddDays(-10),
                DateTime.Now.AddDays(20),
                null,
                Constant.BookingBillStatus.All,
                0,
                999);
            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }

        [TestMethod]
        public void TestQueryPayItemPagedList()
        {
            PagedResult<Entity.EPayItem> result = _service.QueryPayItemPagedList(null, null, Constant.PayItemTypes.All, 0, 999);
            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }


        [TestMethod]
        public void TestQueryMaterialPagedList()
        {
            //PagedResult<View.VMaterial> result = _service.QueryMaterialPagedList(null, null, null, null, Constant.CommonStatus.ALL, 0, 99);

            //Assert.IsTrue(result.IsSuccess);
            //Assert.IsTrue(result.Data.Items.Count > 0);
        }

        [TestMethod]
        public void TestQueryStockPagedList()
        {
            //PagedResult<View.VStock> result = _service.QueryStockPagedList(null, 0, new Guid("347dfbed-efba-49fd-b5f0-40abfe4e6653"), null, null, 0, 99);

            //PagedResult<View.VStock> result = _service.QueryStockPagedList(null, 0, null, new Guid("2ca5bbf5-4f74-496e-8578-7aa6c1601523"), "C0B01", 0, 99);

            PagedResult<View.VStock> result = _service.QueryStockPagedList(null, 0, null, null, "", 0, 99);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }

        [TestMethod]
        public void TestQuerySupplierPagedList()
        {
            PagedResult<View.VSupplier> result = _service.QuerySupplierPagedList(null,
                new Guid("647ae906-43f8-447b-a7ab-90dcd09e41cc"), new Guid("0eb976a2-5a5a-4e67-a434-cd0e70e69aea"), Constant.CommonStatus.ALL, 0, 99);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }

        [TestMethod]
        public void TestQueryMaintenanceBillPageList()
        {
            PagedResult<View.VMaintenanceBill> result = _service.QueryMaintenanceBillPageList(null, null, null, null, null, null, null,null, 0, 99);

            Assert.IsTrue(result.IsSuccess);
            Assert.IsTrue(result.Data.Items.Count > 0);
        }
    }
}
